# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=lab
pkgver=0.25.1
pkgrel=15
pkgdesc="Git Wrapper for GitLab"
url="https://zaquestion.github.io/lab/"
arch="all"
license="CC0-1.0"
depends="git"
makedepends="go"
checkdepends="bash"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="lab-$pkgver.tar.gz::https://github.com/zaquestion/lab/archive/v$pkgver.tar.gz"
options="net !check chmod-clean" # Tests require configured GitLab account with SSH keys

export CGO_ENABLED=0
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -ldflags "-X main.version=$pkgver" -o bin/$pkgname
	./bin/lab completion bash > lab.bash
	./bin/lab completion zsh > _lab.zsh
	./bin/lab completion fish > lab.fish
}

package() {
	install -Dm755 "$builddir"/bin/$pkgname \
		"$pkgdir"/usr/bin/$pkgname
	install -Dm644 "$builddir"/lab.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 "$builddir"/_lab.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
	install -Dm644 "$builddir"/lab.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
}

sha512sums="
891605f0572c9deff27b5583782b59361fd99a2559f9ac84a77f9a9d323ba54b97ac79bfed4ea63e8a421e38a63b3ea713a67c42ecd45ca895d29b2f826e8859  lab-0.25.1.tar.gz
"
